<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.opengis.net/ogc"
   xmlns:ogc="http://www.opengis.net/ogc"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   elementFormDefault="qualified"
   version="1.1.2">

   <xsd:annotation>
      <xsd:documentation>
         This XML Schema defines OGC query filter capabilities documents.
         filter is an OGC Standard.

         Copyright (c) 2002,2003,2004,2010 Open Geospatial Consortium, Inc.
         All Rights Reserved.

         To obtain additional rights of use, visit:
         http://www.opengeospatial.org/legal/ .

         Updated: 2011-02-04
      </xsd:documentation>
   </xsd:annotation>

   <xsd:include schemaLocation="expr.xsd"/>
   <xsd:include schemaLocation="sort.xsd"/>
   <xsd:include schemaLocation="filterCapabilities.xsd"/>

   <xsd:import namespace="http://www.opengis.net/gml"
               schemaLocation="../../gml/3.1.1/base/geometryAggregates.xsd"/>

   <xsd:element name="_Id" type="ogc:AbstractIdType" abstract="true"/>
   <xsd:element name="FeatureId"
                type="ogc:FeatureIdType"
                substitutionGroup="ogc:_Id"/>
   <xsd:element name="GmlObjectId"
                type="ogc:GmlObjectIdType"
                substitutionGroup="ogc:_Id"/>

   <xsd:element name="Filter" type="ogc:FilterType"/>
   <xsd:complexType name="FilterType">
      <xsd:choice>
         <xsd:element ref="ogc:spatialOps"/>
         <xsd:element ref="ogc:comparisonOps"/>
         <xsd:element ref="ogc:logicOps"/>
         <xsd:element ref="ogc:_Id" maxOccurs="unbounded"/>
      </xsd:choice>
   </xsd:complexType>

   <xsd:element name="comparisonOps"
                type="ogc:ComparisonOpsType"
                abstract="true"/>
   <xsd:element name="PropertyIsEqualTo"
                type="ogc:BinaryComparisonOpType"
                substitutionGroup="ogc:comparisonOps"/>
   <xsd:element name="PropertyIsNotEqualTo"
                type="ogc:BinaryComparisonOpType"
                substitutionGroup="ogc:comparisonOps"/>
   <xsd:element name="PropertyIsLessThan"
                type="ogc:BinaryComparisonOpType"
                substitutionGroup="ogc:comparisonOps"/>
   <xsd:element name="PropertyIsGreaterThan"
                type="ogc:BinaryComparisonOpType"
                substitutionGroup="ogc:comparisonOps"/>
   <xsd:element name="PropertyIsLessThanOrEqualTo"
                type="ogc:BinaryComparisonOpType"
                substitutionGroup="ogc:comparisonOps"/>
   <xsd:element name="PropertyIsGreaterThanOrEqualTo"
                type="ogc:BinaryComparisonOpType"
                substitutionGroup="ogc:comparisonOps"/>
   <xsd:element name="PropertyIsLike"
                type="ogc:PropertyIsLikeType"
                substitutionGroup="ogc:comparisonOps"/>
   <xsd:element name="PropertyIsNull"
                type="ogc:PropertyIsNullType"
                substitutionGroup="ogc:comparisonOps"/>
   <xsd:element name="PropertyIsBetween"
                type="ogc:PropertyIsBetweenType"
                substitutionGroup="ogc:comparisonOps"/>
   <xsd:complexType name="ComparisonOpsType" abstract="true"/>
   <xsd:element name="spatialOps" type="ogc:SpatialOpsType" abstract="true"/>
   <xsd:element name="Equals"
                type="ogc:BinarySpatialOpType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="Disjoint"
                type="ogc:BinarySpatialOpType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="Touches"
                type="ogc:BinarySpatialOpType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="Within"
                type="ogc:BinarySpatialOpType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="Overlaps"
                type="ogc:BinarySpatialOpType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="Crosses"
                type="ogc:BinarySpatialOpType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="Intersects"
                type="ogc:BinarySpatialOpType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="Contains"
                type="ogc:BinarySpatialOpType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="DWithin"
                type="ogc:DistanceBufferType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="Beyond"
                type="ogc:DistanceBufferType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:element name="BBOX"
                type="ogc:BBOXType"
                substitutionGroup="ogc:spatialOps"/>
   <xsd:complexType name="SpatialOpsType" abstract="true"/>
   <xsd:element name="logicOps" type="ogc:LogicOpsType" abstract="true"/>
   <xsd:element name="And"
                type="ogc:BinaryLogicOpType"
                substitutionGroup="ogc:logicOps"/>
   <xsd:element name="Or"
                type="ogc:BinaryLogicOpType"
                substitutionGroup="ogc:logicOps"/>
   <xsd:element name="Not"
                type="ogc:UnaryLogicOpType"
                substitutionGroup="ogc:logicOps"/>
   <xsd:complexType name="LogicOpsType" abstract="true"/>
   <xsd:complexType name="AbstractIdType" abstract="true"/>
   <xsd:complexType name="FeatureIdType">
      <xsd:complexContent>
         <xsd:extension base="ogc:AbstractIdType">
            <xsd:attribute name="fid" type="xsd:ID" use="required"/>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="GmlObjectIdType">
      <xsd:complexContent>
         <xsd:extension base="ogc:AbstractIdType">
            <xsd:attribute ref="gml:id" use="required"/>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="BinaryComparisonOpType">
      <xsd:complexContent>
         <xsd:extension base="ogc:ComparisonOpsType">
            <xsd:sequence>
               <xsd:element ref="ogc:expression" minOccurs="2" maxOccurs="2"/>
            </xsd:sequence>
            <xsd:attribute name="matchCase" type="xsd:boolean" use="optional"
                           default="true"/>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="PropertyIsLikeType">
      <xsd:complexContent>
         <xsd:extension base="ogc:ComparisonOpsType">
            <xsd:sequence>
               <xsd:element ref="ogc:PropertyName"/>
               <xsd:element ref="ogc:Literal"/>
            </xsd:sequence>
            <xsd:attribute name="wildCard" type="xsd:string" use="required"/>
            <xsd:attribute name="singleChar" type="xsd:string" use="required"/>
            <xsd:attribute name="escapeChar" type="xsd:string" use="required"/>
            <xsd:attribute name="matchCase" type="xsd:boolean" use="optional"
                           default="true"/>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="PropertyIsNullType">
      <xsd:complexContent>
         <xsd:extension base="ogc:ComparisonOpsType">
            <xsd:sequence>
               <xsd:element ref="ogc:PropertyName"/>
            </xsd:sequence>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="PropertyIsBetweenType">
      <xsd:complexContent>
         <xsd:extension base="ogc:ComparisonOpsType">
            <xsd:sequence>
               <xsd:element ref="ogc:expression"/>
               <xsd:element name="LowerBoundary" type="ogc:LowerBoundaryType"/>
               <xsd:element name="UpperBoundary" type="ogc:UpperBoundaryType"/>
            </xsd:sequence>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="LowerBoundaryType">
      <xsd:choice>
         <xsd:element ref="ogc:expression"/>
      </xsd:choice>
   </xsd:complexType>
   <xsd:complexType name="UpperBoundaryType">
      <xsd:sequence>
         <xsd:element ref="ogc:expression"/>
      </xsd:sequence>
   </xsd:complexType>
   <xsd:complexType name="BinarySpatialOpType">
      <xsd:complexContent>
         <xsd:extension base="ogc:SpatialOpsType">
            <xsd:sequence>
               <xsd:element ref="ogc:PropertyName"/>
               <xsd:choice>
                  <xsd:element ref="ogc:PropertyName"/>
                  <xsd:element ref="gml:_Geometry"/>
                  <xsd:element ref="gml:Envelope"/>
               </xsd:choice>
            </xsd:sequence>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="BBOXType">
      <xsd:complexContent>
         <xsd:extension base="ogc:SpatialOpsType">
            <xsd:sequence>
               <xsd:element ref="ogc:PropertyName" minOccurs="0"/>
               <xsd:element ref="gml:Envelope"/>
            </xsd:sequence>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="DistanceBufferType">
      <xsd:complexContent>
         <xsd:extension base="ogc:SpatialOpsType">
            <xsd:sequence>
               <xsd:element ref="ogc:PropertyName"/>
               <xsd:element ref="gml:_Geometry"/>
               <xsd:element name="Distance" type="ogc:DistanceType"/>
            </xsd:sequence>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="DistanceType">
      <xsd:simpleContent>
         <xsd:extension base="xsd:double">
            <xsd:attribute name="units" type="xsd:anyURI" use="required"/>
         </xsd:extension>
      </xsd:simpleContent>
   </xsd:complexType>
   <xsd:complexType name="BinaryLogicOpType">
      <xsd:complexContent>
         <xsd:extension base="ogc:LogicOpsType">
            <xsd:choice minOccurs="2" maxOccurs="unbounded">
               <xsd:element ref="ogc:comparisonOps"/>
               <xsd:element ref="ogc:spatialOps"/>
               <xsd:element ref="ogc:logicOps"/>
               <xsd:element ref="ogc:Function"/>
            </xsd:choice>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="UnaryLogicOpType">
      <xsd:complexContent>
         <xsd:extension base="ogc:LogicOpsType">
            <xsd:sequence>
               <xsd:choice>
                  <xsd:element ref="ogc:comparisonOps"/>
                  <xsd:element ref="ogc:spatialOps"/>
                  <xsd:element ref="ogc:logicOps"/>
                  <xsd:element ref="ogc:Function"/>
               </xsd:choice>
            </xsd:sequence>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
</xsd:schema>
